package ;

class BackendAPI 
{
    public function new() {}
    
    public function doAnything ():Void
    {
        
    }
    
    public function getString ():String 
    {
        return "hallo";
    }
    
    public function hello (name:String):String 
    {
        return "hallo " + name;
    }
    
    public function throwEx ():Void 
    {
        throw { message:"This is an Error", code: 5 };
        return null;
    }
    
    public function make (user:String, id:Int, age:Int):String 
    {
        return "hallo " + user + " mit der id " + id + " und dem alter " + age;
    }
    
    public function getObj (): { name:String, age:Int } 
    {
         return {name:"Amore", age:18};
    }
    
    public function getDBResult () :List<{id:Int, username:String}>
    {
         var conn = php.db.Mysql.connect( { user:"root", socket:null, port:null, pass:"pphh18111981", database:"wmprophet", host:"localhost" } );
         var res = conn.request("SELECT id, username FROM users LIMIT 0,20");
         
         //return cast res.results();
          return Lambda.map(res.results(), function (elem) return { id:Std.int(elem.id), username:Std.string(elem.username) } );
    }
}